home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 February: Tool Chest / Apple_Developer_Group_CD_Series_February_1998_Tool_Chest.iso / Sample Code / Sound PreMixer effect / Sound PreMixer read me < prev    next >
Encoding:
Text File  |  1997-06-18  |  2.1 KB  |  39 lines  |  [TEXT/R*ch]

  1. Sound PreMixer effect is a sample that shows how to make a pre-mixer component.
  2.  
  3. A pre-mixer component is a component that sees the sound data for a particular sound channel right before the data goes to the Apple Mixer component to be mixed with the sound data from all the other currently playing sound channels.
  4.  
  5. A pre-mixer component can do anything to the sound data it sees, _except_ generate more data (i.e., a reverb effect can't trail off longer than the original sound).
  6.  
  7. This pre-mixer sample implements a simple peak-hold meter.  All it does is watch the sound stream coming by and find the largest sample value in the buffer.  It remembers this value and when asked it will return what the peak sample value was.
  8.  
  9. A pre-mixer component is installed into a sound channel thusly:
  10.  
  11.     SoundComponentLink myLink;
  12.  
  13.     theErr = SndNewChannel (&theSndChannel, sampledSynth, 0, CallBack);
  14.     if (theErr != noErr) DebugStr ("\pSndNewChannel failed");
  15.  
  16.     /* define the type of the localization component */
  17.     myLink.description.componentType = kSoundEffectsType;    //'snfx'
  18.     myLink.description.componentSubType = 'VU-M';    //our VU-meter
  19.     myLink.description.componentManufacturer = 0;
  20.     myLink.description.componentFlags = 0;
  21.     myLink.description.componentFlagsMask = 0;
  22.     myLink.mixerID = nil;
  23.     myLink.linkID = nil;
  24.  
  25.     /* install the localization component BEFORE the Apple Mixer */
  26.     theErr = SndSetInfo (theSndChannel, siPreMixerSoundComponent, &myLink);
  27.  
  28. When your application wants to talk to the pre-mixer effect component it does it like this:
  29.  
  30.     theErr = SndGetInfo (theSndChannel, 'VMtr', &level);    //get the VU-meter level
  31.  
  32. level will contain the peak level that the pre-mixer component saw in the previous buffer.
  33.  
  34. This is the best way to monitor the output of a specific sound channel.
  35.  
  36. Before you ask, there is no easy way to monitor the output of the Mixer component, though you might want to try to write an output component that takes over the real output component (that's the only thing I can think of that might work).
  37.  
  38. If you have any comments, questions, or bug reports please direct them to devsupport@apple.com.
  39.